// import { getAllRoleList, isAccountExist } from '@/api/demo/system';
import { BasicColumn, FormSchema } from '@/components/Table';
import { h } from 'vue';
import { Tooltip } from 'ant-design-vue';
import { getAudiencesListAPI } from '@/api/demo/template';
import { useI18n } from "@/hooks/web/useI18n";

const { t } = useI18n();
async function getAudiencesList() {
  const response = await getAudiencesListAPI();
  return response;
}

export const handleCategoryChange = (value: string) => {
  // 在这里添加你需要的逻辑
};
/**
 * transform mock data
 * {
 *  0: '华东分部',
 * '0-0': '华东分部-研发部'
 * '0-1': '华东分部-市场部',
 *  ...
 * }
 */
// export const deptMap = (() => {
//   const pDept = ['华东分部', '华南分部', '西北分部'];
//   const cDept = ['研发部', '市场部', '商务部', '财务部'];

//   return pDept.reduce((map, p, pIdx) => {
//     map[pIdx] = p;

//     cDept.forEach((c, cIndex) => (map[`${pIdx}-${cIndex}`] = `${p}-${c}`));

//     return map;
//   }, {});
// })();
//表头数据
const Type = [
  {
    label: t('sys.informaionMatchaing.columns.match'),
    value: 'match',
  },
  {
    label: t('sys.informaionMatchaing.columns.orientation'),
    value: 'orientation',
  },
];
const MatchingType = [
  {
    label: t('sys.configuration.notStart'),
    value: t('sys.configuration.notStart'),
  },
  {
    label: t('sys.configuration.inProgress'),
    value: t('sys.configuration.inProgress'),
  },
  {
    label: t('sys.configuration.taskSucces'),
    value: t('sys.configuration.taskSucces'),
  },
  {
    label: t('sys.configuration.taskStop'),
    value: t('sys.configuration.taskStop'),
  },
];

export const columnsModels: BasicColumn[] = [
  {
    title: t('sys.informaionMatchaing.columns.url'),
    dataIndex: 'url',
    width: 120,
    customRender: ({ text, record }) => {
      return h(
        'a',
        {
          href: text,
          target: '_blank', // 在新标签页中打开链接
        },
        text,
      );
    },
  },
  {
    title: t('sys.informaionMatchaing.columns.title'),
    dataIndex: 'title',
    width: 120,
  },
  {
    title: t('sys.informaionMatchaing.columns.videoTag'),
    dataIndex: 'tag',
    width: 120,
  },
  {
    title: t('sys.informaionMatchaing.columns.dataContent'),
    dataIndex: 'dataContent',
    width: 120,
    customRender: ({ text }: { text: string }) => {
      return h(
        Tooltip,
        {
          title: text,
        },
        [
          h(
            'span',
            {
              style: {
                display: 'inline-block',
                width: '100%',
                height: 'auto',
                overflow: 'hidden',
                textOverflow: 'ellipsis',
                whiteSpace: 'nowrap',
              },
            },
            text,
          ),
        ],
      );
    },
  },
  {
    title: t('sys.informaionMatchaing.columns.matching'),
    dataIndex: 'matching',
    width: 60,
  },
  {
    title: t('sys.informaionMatchaing.columns.matanalyse'),
    dataIndex: 'content',
    width: 120,
    customRender: ({ text }: { text: string }) => {
      return h(
        Tooltip,
        {
          title: text,
        },
        [
          h(
            'span',
            {
              style: {
                display: 'inline-block',
                width: '100%',
                height: 'auto',
                overflow: 'hidden',
                textOverflow: 'ellipsis',
                whiteSpace: 'nowrap',
              },
            },
            text,
          ),
        ],
      );
    },
  },
];
//表头搜素数据
export const searchFormSchema: FormSchema[] = [
  {
    field: 'id',
    label: t('sys.informaionMatchaing.columns.createUsername'),
    component: 'Input',
    colProps: { xs: 24, sm: 12, md: 6, lg: 6, xl: 6 },
  },
  {
    field: 'title',
    label: t('sys.informaionMatchaing.columns.title'),
    component: 'Input',
    colProps: { xs: 24, sm: 12, md: 6, lg: 6, xl: 6 },
  },
  {
    field: 'status',
    label: t('sys.informaionMatchaing.columns.status'),
    component: 'Select',
    colProps: { xs: 24, sm: 12, md: 6, lg: 6, xl: 6 },
    componentProps: {
      options: MatchingType,
    },
  },
  {
    field: 'type',
    label: t('sys.informaionMatchaing.columns.type'),
    component: 'Select',
    colProps: { xs: 24, sm: 12, md: 6, lg: 6, xl: 6 },
    componentProps: {
      options: Type,
    },
  },
];
export const accountFormSchema: FormSchema[] = [
  {
    field: 'title',
    component: 'Input',
    label: t('sys.informaionMatchaing.columns.title'),
    defaultValue: '',
    colProps: {
      span: 24,
    },
    rules: [{ required: true }],
  },
  {
    field: 'remark',
    component: 'InputTextArea',
    label: t('sys.configuration.describe'),
    defaultValue: '',
    colProps: {
      span: 24,
    },
    componentProps: {
      rows: 3, // 设置文本域的行数
    },
    rules: [{ required: true }],
  },
  {
    field: 'category',
    component: 'AutoComplete',
    label: t('sys.informaionMatchaing.columns.category'),
    defaultValue: '',
    colProps: {
      span: 24,
    },
    componentProps: {
      options: MatchingType,
      filterOption: (inputValue, option) => {
        return option.value.toUpperCase().indexOf(inputValue.toUpperCase()) !== -1;
      },
    },
    rules: [{ required: true }],
  },
  {
    field: 'date',
    component: 'DatePicker',
    label: t('sys.informaionMatchaing.columns.DatePicker'),
    defaultValue: '',
    colProps: {
      span: 24,
    },
    componentProps: {
      format: 'YYYY-MM-DD HH:mm:ss', // 设置显示格式
      showTime: true, // 显示时间选择器
      valueFormat: 'YYYY-MM-DD HH:mm:ss', // 设置返回值的格式
    },
    rules: [{ required: true }],
  },
];
//人员匹配
export const accountFormSchemPeople: FormSchema[] = [
  {
    field: 'title',
    component: 'Input',
    label: t('sys.informaionMatchaing.columns.title'),
    defaultValue: '',
    colProps: {
      span: 24,
    },
    rules: [{ required: true }],
  },
  {
    field: 'content',
    component: 'InputTextArea',
    label: t('sys.configuration.describe'),
    defaultValue: '',
    colProps: {
      span: 24,
    },
    componentProps: {
      rows: 3, // 设置文本域的行数
    },
    rules: [{ required: true }],
  },
  {
    field: 'templateId',
    component: 'ApiSelect',
    label: t('sys.informaionMatchaing.columns.advertisement'),
    defaultValue: '',
    colProps: {
      span: 24,
    },
    componentProps: {
      api: getAudiencesList, // 指定接口函数
      resultField: 'data', // 接口返回的数据字段名
      labelField: 'remark', // 选项显示的标签字段名
      valueField: 'id', // 选项的值字段名
    },
  },
];

//定向匹配
